package 变长滑动窗口1

func longestOnes(nums []int, k int) (ans int) {
	s := 0
	left := 0
	for i, num := range nums {
		if num == 0 {
			s++
		}
		for s > k {
			if nums[left] == 0 {
				s--
			}
			left++
		}
		ans = max(ans, i-left+1)
	}
	return
}
